<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/5/30
 * Time: 10:53
 */

$course_price = array(array('3060','19580'),array('4560','26120'),array('19800','19800'));

if(empty($_SESSION['area']))
{
    $UserArea=getAreaByIp();
    $_SESSION['area']=$UserArea['region'];
}

/*$kecheng_type=array(
    '名列前茅|北上|高一'=>array('自招面试长线课程','上纽大直通车','学科辅导','32','自招/竞赛','64','128','高一',),
    '名列前茅|非北上|高一'=>array('自招面试长线课程','上纽大直通车','学科辅导','32','自招/竞赛','64','128','高一',),
    '名列前茅|北上|高二'=>array('自招面试长线课程','上纽大直通车','学科辅导','32','自招/竞赛','64','128','高二',),
    '名列前茅|非北上|高二'=>array('自招面试长线课程','上纽大直通车','学科辅导','32','自招/竞赛','64','128','高二',),
    '名列前茅|北上|高三'=>array('自招面试长线课程','学科辅导','32','64','自招/竞赛','128','高三',),
    '名列前茅|非北上|高三'=>array('自招面试长线课程','学科辅导','32','64','自招/竞赛','128','高三',),
    '名列前茅|北上|初三'=>array('自招/竞赛','32','64','128','学科辅导','初三',),
    '名列前茅|非北上|初三'=>array('自招/竞赛','32','64','128','学科辅导','初三',),
    '名列前茅|北上|初二'=>array('自招/竞赛','32','64','128','学科辅导','初二',),
    '名列前茅|非北上|初二'=>array('自招/竞赛','32','64','128','学科辅导','初二',),
    '名列前茅|北上|初一'=>array('自招/竞赛','32','64','128','学科辅导','初一',),
    '名列前茅|非北上|初一'=>array('自招/竞赛','32','64','128','学科辅导','初一',),

    '中游|北上|高一'=>array('自招面试长线课程','上纽大直通车','自招/竞赛','32','64','高一',),
    '中游|非北上|高一'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','高一',),
    '中游|北上|高二'=>array('自招面试长线课程','上纽大直通车','自招/竞赛','32','64','高二',),
    '中游|非北上|高二'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','高二',),
    '中游|北上|高三'=>array('自招面试长线课程','上纽大直通车','自招/竞赛','32','64','高三',),
    '中游|非北上|高三'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','高三',),
    '中游|北上|初三'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初三',),
    '中游|非北上|初三'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初三',),
    '中游|北上|初二'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初二',),
    '中游|非北上|初二'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初二',),
    '中游|北上|初一'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初一',),
    '中游|非北上|初一'=>array('学科辅导','32','64','128','五星名师','自招/竞赛','初一',),

    '需努力|北上|高一'=>array('学科辅导','32','64','128','五星名师','高一',),
    '需努力|非北上|高一'=>array('学科辅导','32','64','128','五星名师','高一',),
    '需努力|北上|高二'=>array('学科辅导','32','64','128','五星名师','高二',),
    '需努力|非北上|高二'=>array('学科辅导','32','64','128','五星名师','高二',),
    '需努力|北上|高三'=>array('学科辅导','32','64','128','五星名师','高三',),
    '需努力|非北上|高三'=>array('学科辅导','32','64','128','五星名师','高三',),
    '需努力|北上|初三'=>array('学科辅导','32','64','128','五星名师','初三',),
    '需努力|非北上|初三'=>array('学科辅导','32','64','128','五星名师','初三',),
    '需努力|北上|初二'=>array('学科辅导','32','64','128','五星名师','初二',),
    '需努力|非北上|初二'=>array('学科辅导','32','64','128','五星名师','初二',),
    '需努力|北上|初一'=>array('学科辅导','32','64','128','五星名师','初一',),
    '需努力|非北上|初一'=>array('学科辅导','32','64','128','五星名师','初一',),
);*/
$kecheng[1]=array('短期攻坚,突破瓶颈','学科辅导','32课时',);
$kecheng[2]=array('中长期提升,解决短板','学科辅导','64课时',);
$kecheng[3]=array('系统化补强，扎实提升','学科辅导','128课时',);
$kecheng[4]=array('短期名师教学,攻克疑难知识点','学科辅导','32课时','五星名师',);
$kecheng[5]=array('中长期名师指导,解决成绩不稳定现象','学科辅导','64课时','五星名师',);
$kecheng[6]=array('名师长期补强,全面巩固基础知识体系','学科辅导','128课时','五星名师',);
$kecheng[7]=array('加强学科知识创新力,提升升学质量','自招/竞赛','32课时',);
$kecheng[8]=array('针对性训练竞赛技巧,提升名校录取机会','自招/竞赛','64课时',);
$kecheng[9]=array('系统性提升知识运用能力,增加竞赛获奖机会','自招/竞赛','128课时',);
$kecheng[10]=array('升学咨询、找准专业、提升面试技巧等全方位服务','自招面试长线课程',);
$kecheng[11]=array('口语训练+经历塑造+高阶申请+升学顾问=4重镀金','上纽大直通车',);
$kecheng_type=array(
    '名列前茅|北上|高一'=>array($kecheng[10],$kecheng[11],$kecheng[1],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|非北上|高一'=>array($kecheng[10],$kecheng[11],$kecheng[1],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|北上|高二'=>array($kecheng[10],$kecheng[11],$kecheng[1],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|非北上|高二'=>array($kecheng[10],$kecheng[11],$kecheng[1],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|北上|高三'=>array($kecheng[10],$kecheng[1],$kecheng[2],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|非北上|高三'=>array($kecheng[10],$kecheng[1],$kecheng[2],$kecheng[7],$kecheng[8],$kecheng[9]),
    '名列前茅|北上|初三'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),
    '名列前茅|非北上|初三'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),
    '名列前茅|北上|初二'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),
    '名列前茅|非北上|初二'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),
    '名列前茅|北上|初一'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),
    '名列前茅|非北上|初一'=>array($kecheng[7],$kecheng[8],$kecheng[9],$kecheng[1],$kecheng[2],$kecheng[3]),

    '中游|北上|高一'=>array($kecheng[10],$kecheng[11],$kecheng[12],$kecheng[7],$kecheng[8]),
    '中游|非北上|高一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|北上|高二'=>array($kecheng[10],$kecheng[11],$kecheng[12],$kecheng[7],$kecheng[8]),
    '中游|非北上|高二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|北上|高三'=>array($kecheng[10],$kecheng[11],$kecheng[12],$kecheng[7],$kecheng[8]),
    '中游|非北上|高三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|北上|初三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|非北上|初三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|北上|初二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|非北上|初二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|北上|初一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),
    '中游|非北上|初一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[8]),

    '需努力|北上|高一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|高一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|北上|高二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|高二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|北上|高三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|高三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|北上|初三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|初三'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|北上|初二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|初二'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|北上|初一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
    '需努力|非北上|初一'=>array($kecheng[1],$kecheng[2],$kecheng[3],$kecheng[4],$kecheng[5],$kecheng[6]),
);
if(!empty($_REQUEST['act'])&&$_REQUEST['act']=='helper'){
    $rank=$_POST['rank'];
    $grade=$_POST['grade'];
    $isGaozhong=true;
    if(strpos($grade,'高')===false)
    {
        $isGaozhong=false;
    }
    $area=$_SESSION['area'];
    if(strpos($area,'上海')!==false||strpos($area,'北京')!==false)
    {
        $area='北上';
    }else{
        $area='非北上';
    }
    $key=$rank.'|'.$area.'|'.$grade;
    $helper_attrs=$kecheng_type[$key];
    foreach($helper_attrs as $k=>&$v)
    {
        $vip='';
        $attr_url=array($isGaozhong?'1':'0');
        $mobile_attr_url=array($isGaozhong?'1':'0');
        $words=array('学科','自招','面试','上纽大');
        foreach($words as $m=>$n)
        {
            if(strpos($v[1],$n)!==false)
            {
                $sql="select cat_id from ".$ecs->table('category')." category where parent_id='0' and cat_name like '%$n%'";
                $mobile_attr_url[1]=$attr_url[1]=$db->getOne($sql);
            }
        }
        $sql="select cat_id from ".$ecs->table('category')." category where parent_id='".$mobile_attr_url[1]."' and cat_name='$grade'";
        $mobile_attr_url[2]=$db->getOne($sql);
        $attr_tag=false;
        $temp_url_cat=array('','');
        if(strpos($v[3],'五星')!==false)
        {
            $attr_tag=true;
            $sql="select cat_id from ".$ecs->table('category')." category where cat_name like '%五星%'";
            $tmp_sub_cat=$db->getOne($sql);
            $temp_url_cat[0]=$tmp_sub_cat;
            $vip='&vip='.$tmp_sub_cat;
        }
        if(!$attr_tag){
            $sql="select cat_id from ".$ecs->table('category')." category where parent_id='".$attr_url[1]."' and cat_name like '%".$grade."%'";
            $attr_url[]=$db->getOne($sql);
        }
        $temp_url_cat[1]=$grade;
        $attr_url[2]=join('_',$temp_url_cat);
        if($v[2])
        {
            $keshi=str_replace('课时','',$v[2]);
            $sql="select cat_id from ".$ecs->table('category')." category where parent_id='".$attr_url[1]."' and cat_name like '%".$grade."%'";
            $attr_url[]=$db->getOne($sql);
            $attr_url[3]=$keshi;
            $mobile_attr_url[3]=$keshi;
        }

        $v[10]=join('-',$attr_url).$vip;
        $v[11]=join('-',$mobile_attr_url).$vip;
    }
    $temp_arr=array();

        foreach($helper_attrs as $k=>&$v)
        {
            if(!empty($_REQUEST['mobile'])){
                unset($v[10]);
            }else{
                unset($v[11]);
            }
            $temp_arr[$k]['url']='goods.php?cat='.array_pop($v);
            $temp_arr[$k]['brief']=array_shift($v);

            $temp_arr[$k]['title']=join('+',$v);

        }

    if(empty($temp_arr))
    {
        exit(returnFail('暂时没有对应课程','no_course'));
    }
    exit(returnSuccess($temp_arr));


}




